#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QFileDialog>
#include<QDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow),i(0)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_btnSlt_clicked()
{
    QStringList files = QFileDialog::getOpenFileNames(this,"选择图片",".","Images(*.png *.jpg *.bmp)");
    qDebug()<<files;
    ui->picList->clear();
    ui->picList->appendPlainText(files.join("\n"));
    fs = files;
    ui->labelPic->setPixmap(QPixmap(fs[0]));
}

void MainWindow::on_btnPs_clicked()
{
    i--;
    if(i<0){
        i = 0;
    }
    ui->labelPic->setPixmap(QPixmap(fs[i]));
}

void MainWindow::on_btnNt_clicked()
{
    i++;
    if(i == fs.length()){
        i = fs.length()-1;
    }
    ui->labelPic->setPixmap(QPixmap(fs[i]));
}
